**********************************************************************************************************
* Replication Code
* Sharing the Risk? Households, labor market vulnerability and social policy preferences in Western Europe
* Silja H�usermann, Thomas Kurer and Hanna Schwander
* Journal of Politics, 2016
**********************************************************************************************************

* Code to create group- and country specific outsiderness values based on EU-SILC data
* Files to merge EU-SILC and ESS-data are created and saved at the end of this script

version 13clear all
cd "/Volumes/projects$/dualization/replicationJoP"
* Use EU-SILC 2007, Version 3 from 01-03-10
* confidentiality undertaking prohibits granting access to these data
* apply for microdata: http://tinyurl.com/gpkjs4t

use "UDB_c07P_ver 2007-3 from 01-03-10.dta"set more off


***********************************************************************
* 1. Create occupational groups***********************************************************************
label var pl030 "self-defined current economic status"#delimit;label define pl0301 "Working full time"2 "Working part-time"3 "Unemployed"4 "student, pubil, unpaid work experience"5 "in retirement"6 "Permantently disable, unfit to work"7 "military service"8 "fullfilling domestic tasks and care responsibilitites"9 "other inactive person", modify;label values pl030 pl030;#delimit cr*** Switzerlandlabel var pl031 "self-defined current economic status"#delimit;label define pl0311 "Employee working full-time"2 "Employee working part-time"3 "Self-employed working full-time (including family worker)"4 "Self-employed working part-time (including family worker)"5 "Unemployed"6 "Pupil, student, further training, unpaid work experience"7 "In retirement or in early retirement or has given up business"8 "Permanently disabled or/and unfit to work"9 "In compulsory military community or service"10 "Fulfilling domestic tasks and care responsibilities"11 "Other inactive person", modify;label values pl031 pl031;#delimit crlabel var pl040 "Status in employment"#delimit;label define pl0401 "Self-employed with employees"2 "self-employed without employees"3 "Employee"4 "familiy worker", modify;label values pl040 pl040;#delimit crlabel var pl120 "Reason for working less than 30 hours"#delimit;label define pl1201 "Undergoing education or training"2 "personal illness or disability"3 "Want to work more hours but connot find a job of more hours"4 "Do not want to work more hours"5 " Nr of hours in all jobs are considered as full time"6 "Housework, looking after children or other persons"7 "other reasons", modify;label values pl120 pl120;#delimit crlabel var pl140 "Type of contract"#delimit;label define pl1401 "permantent job contract"2 "temporary job of limited duration", modify;label values pl140 pl140;#delimit cr /*gender*/gen gender=.replace gender=1 if pb150==2replace gender=0 if pb150==1label var gender "gender"#delimit;label define gender1 "female"0 "male", modify;label values gender gender;#delimit cr/* young dummy */drop if pb140<=1926gen age=2007-pb140gen young=.replace young=1 if age<=40replace young=0 if age>40label var young "young, under 40"#delimit;label define young1 "below40"0 "over40", modify;label values young young;#delimit cr/*socio-econominc groups: Kitschelt und Rehm groups; self employed and unemployed are included in this variable */
gen isco88_2d=pl050label var isco88_2d "Respondent's occupational code (in ISCO88-2d)"gen groups=.replace groups=1 if isco88_2d==11 | isco88_2d==12 | isco88_2d==13 | isco88_2d==21replace groups=2 if isco88_2d==41 | isco88_2d==42 | isco88_2d==31replace groups=3 if isco88_2d==61 | isco88_2d==92 ///  | isco88_2d==81 | isco88_2d==82 | isco88_2d==83 | isco88_2d==93 ///  | isco88_2d==71 | isco88_2d==72 | isco88_2d==73 | isco88_2d==74replace groups=4 if isco88_2d==22 | isco88_2d==23 | isco88_2d==24 ///  | isco88_2d==32 | isco88_2d==33 | isco88_2d==34replace groups=5 if isco88_2d==51 | isco88_2d==52 | isco88_2d == 91label var groups "Socio-economic groups (HK & PhR)"#delimit;label define groups  1 "Capital accumulators"2 "Mixed service functionaires"3 "Blue and lower white collar"4 "Socio-cultural (semi-)professionals"5 "Low service functionaires", modify;label values groups groups;#delimit cr/*create 20 exclusive social groups
(baseline groups for continuous measure of labor market vulnerability)*//*young women*/gen youngfemale=.la var youngfemale "young women"replace youngfemale=1 if gender==1 & young==1replace youngfemale=0 if gender==0 | young==0#delimit;label define youngfemale 1 "young female"0 "else", modify;la val youngfemale youngfemale;#delimit cr/*young men*/gen youngmale =.la var youngmale "young men"replace youngmale =1 if gender==0 & young==1replace youngmale =0 if gender==1 | young==0#delimit;label define youngmale 1 "young male"0 "else", modify;la val youngmale youngmale;#delimit cr/*Old women*/gen oldfemale=.la var oldfemale "old women"replace oldfemale =1 if gender==1 & young==0replace oldfemale =0 if gender==0 | young==1#delimit;label define oldfemale1 "old female"0 "else", modify;la val oldfemale oldfemale;#delimit cr/*Old Men*/gen oldmale=.la var oldmale "old men"replace oldmale=1 if gender==0 & young==0replace oldmale=0 if gender==1 | young==1#delimit;label define oldmale1 "old male"0 "else", modify;la val oldmale oldmale;#delimit crgen LSF_female=.replace LSF_female=1 if groups==5 & gender==1replace LSF_female=0 if groups==5 & gender==0replace LSF_female=0 if groups==1replace LSF_female=0 if groups==2replace LSF_female=0 if groups==3replace LSF_female=0 if groups==4label var LSF_female "LSF_female"#delimit;label define LSF_female1 "LSF_female"0 "else", modify;label values LSF_female LSF_female;#delimit crgen LSF_young=.replace LSF_young=1 if groups==5 & young==1replace LSF_young=0 if groups==5 & young==0replace LSF_young=0 if groups==1replace LSF_young=0 if groups==2replace LSF_young=0 if groups==3replace LSF_young=0 if groups==4label var LSF_young "LSF_young"#delimit;label define LSF_young1 "LSF_young"0 "else", modify;label values LSF_young LSF_young;#delimit crgen SCP_female=.replace SCP_female=1 if groups==4 & gender==1replace SCP_female=0 if groups==4 & gender==0replace SCP_female=0 if groups==1replace SCP_female=0 if groups==2replace SCP_female=0 if groups==3replace SCP_female=0 if groups==5label var SCP_female "SCP_female"#delimit;label define SCP_female1 "SCP_female"0 "else", modify;label values SCP_female SCP_female;#delimit crgen SCP_young=.replace SCP_young=1 if groups==4 & young==1replace SCP_young=0 if groups==4 & young==0replace SCP_young=0 if groups==1replace SCP_young=0 if groups==2replace SCP_young=0 if groups==3replace SCP_young=0 if groups==5label var SCP_young "SCP_young"#delimit;label define SCP_young1 "SCP_young"0 "else", modify;label values SCP_young SCP_young;#delimit crgen LSF_male=.replace LSF_male=1 if groups==5 & gender==0replace LSF_male=0 if groups==5 & gender==1replace LSF_male=0 if groups==1replace LSF_male=0 if groups==2replace LSF_male=0 if groups==3replace LSF_male=0 if groups==4label var LSF_male "LSF_male"#delimit;label define LSF_male1 "LSF_male"0 "else", modify;label values LSF_male LSF_male;#delimit crgen LSF_old=.replace LSF_old=1 if groups==5 & young==0replace LSF_old=0 if groups==5 & young==1replace LSF_old=0 if groups==1replace LSF_old=0 if groups==2replace LSF_old=0 if groups==3replace LSF_old=0 if groups==4label var LSF_old "LSF_old"#delimit;label define LSF_old1 "LSF_old"0 "else", modify;label values LSF_old LSF_old;#delimit crgen SCP_male=.replace SCP_male=1 if groups==4 & gender==0replace SCP_male=0 if groups==4 & gender==1replace SCP_male=0 if groups==1replace SCP_male=0 if groups==2replace SCP_male=0 if groups==3replace SCP_male=0 if groups==5label var SCP_male "SCP_male"#delimit;label define SCP_male1 "SCP_male"0 "else", modify;label values SCP_male SCP_male;#delimit crtab SCP_malegen SCP_old=.replace SCP_old=1 if groups==4 & young==0replace SCP_old=0 if groups==4 & young==1replace SCP_old=0 if groups==1replace SCP_old=0 if groups==2replace SCP_old=0 if groups==3replace SCP_old=0 if groups==5label var SCP_old "SCP_old"#delimit;label define SCP_old1 "SCP_old"0 "else", modify;label values SCP_old SCP_old;#delimit crgen BC=.replace BC=1 if groups==3 replace BC=0 if groups==1replace BC=0 if groups==2replace BC=0 if groups==4replace BC=0 if groups==5label var BC "Blue collar workers"#delimit;label define BC1 "BC"0 "else", modify;label values BC BC;#delimit crgen MSF=.replace MSF=1 if groups==2replace MSF=0 if groups==1replace MSF=0 if groups==3replace MSF=0 if groups==4replace MSF=0 if groups==5label var MSF "Mixed service functionaries"#delimit;label define MSF1 "MSF"0 "else", modify;label values MSF MSF;#delimit crgen CA=.replace CA=1 if groups==1 replace CA=0 if groups==2replace CA=0 if groups==3replace CA=0 if groups==4replace CA=0 if groups==5label var CA "Capital accumulators"#delimit;label define CA1 "CA"0 "else", modify;label values CA CA;#delimit cr/*LSF_youngfemale*/gen LSF_youngfemale=.la var LSF_youngfemale "LSF young women"replace LSF_youngfemale=1 if youngfemale==1 & groups==5 replace LSF_youngfemale=0 if youngfemale==1 & groups!=5replace LSF_youngfemale=0 if youngfemale==0la de LSF_youngfemale 1 "LSF young female" 0 "else", modifyla val LSF_youngfemale LSF_youngfemale /*LSF young male*/gen LSF_youngmale=.la var LSF_youngmale "LSF young men"replace LSF_youngmale=1 if youngmale==1 & groups==5 replace LSF_youngmale=0 if youngmale==1 & groups!=5replace LSF_youngmale=0 if youngmale==0la de LSF_youngmale 1 "LSF young male" 0 "else", modifyla val LSF_youngmale LSF_youngmaletab LSF_youngmale LSF_youngfemale/*LSF_oldfemale*/gen LSF_oldfemale=.la var LSF_oldfemale "LSF old Women"replace LSF_oldfemale=1 if oldfemale==1 & groups==5replace LSF_oldfemale=0 if oldfemale==0replace LSF_oldfemale=0 if oldfemale==1 & groups!=5la de LSF_oldfemale 1 "LSF old female" 0 "else", modifyla val LSF_oldfemale LSF_oldfemale/*LSF_oldmale*/gen LSF_oldmale=.la var LSF_oldmale "LSF Old Men"replace LSF_oldmale=1 if oldmale==1 & groups==5replace LSF_oldmale=0 if oldmale==1 & groups!=5replace LSF_oldmale=0 if oldmale==0la de LSF_oldmale 1 "LSF old male" 0 "else", modifyla val LSF_oldmale LSF_oldmaletab LSF_oldmale LSF_oldfemaletab LSF_youngmale LSF_oldmale /*SCP_youngfemale*/gen SCP_youngfemale=.la var SCP_youngfemale "SCP young women"replace SCP_youngfemale=1 if youngfemale==1 & groups==4 replace SCP_youngfemale=0 if youngfemale==1 & groups!=4replace SCP_youngfemale=0 if youngfemale==0la de SCP_youngfemale 1 "SCP young female" 0 "else", modifyla val SCP_youngfemale SCP_youngfemale/*SCP young male*/gen SCP_youngmale=.la var SCP_youngmale "SCP young men"replace SCP_youngmale=1 if youngmale==1 & groups==4replace SCP_youngmale=0 if youngmale==1 & groups!=4replace SCP_youngmale=0 if youngmale==0la de SCP_youngmale 1 "SCP young male" 0 "else", modifyla val SCP_youngmale SCP_youngmale tab SCP_youngmale SCP_youngfemale/*SCP_oldfemale*/gen SCP_oldfemale=.la var SCP_oldfemale "SCP old Women"replace SCP_oldfemale=1 if oldfemale==1 & groups==4replace SCP_oldfemale=0 if oldfemale==0replace SCP_oldfemale=0 if oldfemale==1 & groups!=4la de SCP_oldfemale 1 "SCP old female" 0 "else", modifyla val SCP_oldfemale SCP_oldfemale/*SCP_oldmale*/gen SCP_oldmale=.la var SCP_oldmale "SCP Old Men"replace SCP_oldmale=1 if oldmale==1 & groups==4replace SCP_oldmale=0 if oldmale==1 & groups!=4replace SCP_oldmale=0 if oldmale==0la de SCP_oldmale 1 "SCP old male" 0 "else", modifyla val SCP_oldmale SCP_oldmaletab SCP_oldmale SCP_oldfemale/*BC_youngfemale*/gen BC_youngfemale=.la var BC_youngfemale "BC young women"replace BC_youngfemale=1 if youngfemale==1 & groups==3 replace BC_youngfemale=0 if youngfemale==1 & groups!=3replace BC_youngfemale=0 if youngfemale==0la de BC_youngfemale 1 "BC young female" 0 "else", modifyla val BC_youngfemale BC_youngfemale/*BC young male*/gen BC_youngmale=.la var BC_youngmale "BC young men"replace BC_youngmale=1 if youngmale==1 & groups==3replace BC_youngmale=0 if youngmale==1 & groups!=3replace BC_youngmale=0 if youngmale==0la de BC_youngmale 1 "BC young male" 0 "else", modifyla val BC_youngmale BC_youngmale/*BC_oldfemale*/gen BC_oldfemale=.la var BC_oldfemale "BC old Women"replace BC_oldfemale=1 if oldfemale==1 & groups==3replace BC_oldfemale=0 if oldfemale==1 & groups!=3replace BC_oldfemale=0 if oldfemale==0la de BC_oldfemale 1 "BC old female" 0 "else", modifyla val BC_oldfemale BC_oldfemale/*BC_oldmale*/gen BC_oldmale=.la var BC_oldmale "BC Old Men"replace BC_oldmale=1 if oldmale==1 & groups==3replace BC_oldmale=0 if oldmale==1 & groups!=3replace BC_oldmale=0 if oldmale==0la de BC_oldmale 1 "BC old male" 0 "else", modifyla val BC_oldmale BC_oldmaletab BC_oldmale BC_oldfemaletab BC_youngmale BC_youngfemale/*MSF_youngfemale*/gen MSF_youngfemale=.la var MSF_youngfemale "MSF young women"replace MSF_youngfemale=1 if youngfemale==1 & groups==2replace MSF_youngfemale=0 if youngfemale==1 & groups!=2replace MSF_youngfemale=0 if youngfemale==0la de MSF_youngfemale 1 "MSF young female" 0 "else", modifyla val MSF_youngfemale MSF_youngfemale/*MSF young male*/gen MSF_youngmale=.la var MSF_youngmale "MSF young men"replace MSF_youngmale=1 if youngmale==1 & groups==2replace MSF_youngmale=0 if youngmale==1 & groups!=2replace MSF_youngmale=0 if youngmale==0la de MSF_youngmale 1 "MSF young male" 0 "else", modifyla val MSF_youngmale MSF_youngmale/*MSF_oldfemale*/gen MSF_oldfemale=.la var MSF_oldfemale "MSF old Women"replace MSF_oldfemale=1 if oldfemale==1 & groups==2replace MSF_oldfemale=0 if oldfemale==1 & groups!=2replace MSF_oldfemale=0 if oldfemale==0la de MSF_oldfemale 1 "MSF old female" 0 "else", modifyla val MSF_oldfemale MSF_oldfemale/*MSF_oldmale*/gen MSF_oldmale=.la var MSF_oldmale "BC Old Men"replace MSF_oldmale=1 if oldmale==1 & groups==2replace MSF_oldmale=0 if oldmale==1 & groups!=2replace MSF_oldmale=0 if oldmale==0la de MSF_oldmale 1 "MSF old male" 0 "else", modifyla val MSF_oldmale MSF_oldmaletab MSF_oldmale MSF_oldfemaletab MSF_youngmale MSF_youngfemale/*CA_youngfemale*/gen CA_youngfemale=.la var CA_youngfemale "CA young women"replace CA_youngfemale=1 if youngfemale==1 & groups==1replace CA_youngfemale=0 if youngfemale==1 & groups!=1replace CA_youngfemale=0 if youngfemale==0la de CA_youngfemale 1 "CA young female" 0 "else", modifyla val CA_youngfemale CA_youngfemale/*CA young male*/gen CA_youngmale=.la var CA_youngmale "CA young men"replace CA_youngmale=1 if youngmale==1 & groups==1replace CA_youngmale=0 if youngmale==1 & groups!=1replace CA_youngmale=0 if youngmale==0la de CA_youngmale 1 "CA young male" 0 "else", modifyla val CA_youngmale CA_youngmale/*CA_oldfemale*/gen CA_oldfemale=.la var CA_oldfemale "CA old Women"replace CA_oldfemale=1 if oldfemale==1 & groups==1replace CA_oldfemale=0 if oldfemale==1 & groups!=1replace CA_oldfemale=0 if oldfemale==0la de CA_oldfemale 1 "CA old female" 0 "else", modifyla val CA_oldfemale CA_oldfemale/*CA_oldmale*/gen CA_oldmale=.la var CA_oldmale "BC Old Men"replace CA_oldmale=1 if oldmale==1 & groups==1replace CA_oldmale=0 if oldmale==1 & groups!=1replace CA_oldmale=0 if oldmale==0la de CA_oldmale 1 "CA old male" 0 "else", modifyla val CA_oldmale CA_oldmaletab CA_oldmale CA_oldfemaletab CA_youngmale CA_youngfemale su CA**Variable that contains all exl.groups*gen exlgroups=.la var exlgroups "socio-economic groups (excl)"replace exlgroups =1 if LSF_youngfemale ==1replace exlgroups =2 if LSF_youngmale ==1replace exlgroups =3 if LSF_oldfemale ==1replace exlgroups =4 if LSF_oldmale ==1replace exlgroups =5 if SCP_youngfemale ==1replace exlgroups =6 if SCP_youngmale ==1replace exlgroups =7 if SCP_oldfemale ==1replace exlgroups =8 if SCP_oldmale ==1replace exlgroups =9 if BC_youngfemale ==1replace exlgroups =10 if BC_youngmale ==1replace exlgroups =11 if BC_oldfemale ==1replace exlgroups =12 if BC_oldmale ==1replace exlgroups =13 if MSF_youngfemale ==1replace exlgroups =14 if MSF_youngmale ==1replace exlgroups =15 if MSF_oldfemale ==1replace exlgroups =16 if MSF_oldmale ==1replace exlgroups =17 if CA_youngfemale ==1replace exlgroups =18 if CA_youngmale ==1replace exlgroups =19 if CA_oldfemale ==1replace exlgroups =20 if CA_oldmale ==1#delimitla de exlgroups1 "LSF_youngfemale"2 "LSF_youngmale"3 "LSF_oldfemale"4 "LSF_oldmale"5 "SCP_youngfemale"6 "SCP_youngmale"7 "SCP_oldfemale"8 "SCP_oldmale"9 "BC_youngfemale"10 "BC_youngmale"11 "BC_oldfemale"12 "BC_oldmale"13 "MSF_youngfemale"14 "MSF_youngmale"15 "MSF_oldfemale"16 "MSF_oldmale"17 "CA_youngfemale"18 "CA_youngmale"19 "CA_oldfemale"20 "CA_oldmale", modify;la val exlgroups exlgroups;#delimit crtab exlgroupstab exlgroups, nolabel***********************************************************************
* 2. Create/Recode vulnerability variables
***********************************************************************
** Part-time **gen parttime=0replace parttime=1 if pl030==2 replace parttime=0 if pl030==1 *replace parttime=0 if pl030>=3 *** Switzerlandreplace parttime=1 if pl031==2 & pb020=="CH"replace parttime=1 if pl031==4 & pb020=="CH"replace parttime=0 if pl031==1 & pb020=="CH"*replace parttime=0 if pl031>=3 & pb020=="CH"replace parttime=0 if pl120==4label var parttime "part-time dummy"#delimit;label define parttime1 "parttime"0 "NOT parttime", modify;label values parttime parttime;#delimit crtab pl030 parttime** Temporary contracted **gen temp=.replace temp=1 if pl140==2replace temp=0 if pl140==1la var temp "fixed term dummy"#delimit;la de temp	1 "fixed term contracted"0 "Permantent contracted", modify;label values temp temp;#delimit cr** Unemployment **gen unempl=.replace unempl=1 if pl031==5 & pb020=="CH" /*unempl Switzerland*/replace unempl=0 if pl031==2 & pb020=="CH"replace unempl=0 if pl031==1 & pb020=="CH"replace unempl=0 if pl031==3 & pb020=="CH"replace unempl=0 if pl031==4 & pb020=="CH"replace unempl=0 if pl031==7 & pb020=="CH"replace unempl=0 if pl031==9 & pb020=="CH"replace unempl=1 if pl030==3 & pb020!="CH" /*unempl all other countries*/replace unempl=0 if pl030==2 & pb020!="CH"replace unempl=0 if pl030==1 & pb020!="CH"replace unempl=0 if pl030==5 & pb020!="CH"replace unempl=0 if pl030==7 & pb020!="CH"label var unempl "unemployed dummy"#delimit;label define unempl1 "unemployed"0 "NOT unemployed", modify;label values unempl unempl;#delimit cr***********************************************************************
* 3. Create outsiderness
************************************************************************* Temp work (incl. family business) **gen temp_plus = tempreplace temp_plus = 1 if pl040==4 tab temp_plus templabel variable temp_plus "fixed term plus dummy"label value temp_plus fixedtermpluslabel define fixedtermplus 0 "permanent contracted" 1 "temporary or family worker", modify

/* Atypical Dummy: Unemployment as a Form of atypical Employment*/

gen atypical=.
replace atypical=1 if temp_plus==1
replace atypical=1 if parttime==1
replace atypical=1 if pl040==4
replace atypical=1 if unempl==1

replace atypical=0 if pl030==1 & temp!=1

replace atypical=0 if pl031==1 & temp!=1 & pb020=="CH"

la var atypical "atypical dummy"

la de atypical 1 "atypical" 0 "NOT atypical", modify
la val atypical atypical

gen NOT_atypical = atypical==0
label variable NOT_atypical "Not atypically employed dummy"
bysort exlgroup pb020: egen nr_cn = total(atypical)
label variable nr_cn "Number of atypically employed, by Country"

bysort exlgroup pb020: egen nr_not_cn = total(NOT_atypical)
label variable nr_not_cn "Number of NOT atypically employed, by Country"

gen nr_total_cn = nr_cn + nr_not_cn
label variable nr_total_cn "Number of atypically or NOT atypically employed people (total without missings), by Country"
* 3.1 Group-specific vulnerability values** temp work **bysort exlgroup pb020: egen nr_temp_plus_cn = total(temp_plus)gen temp_plus_rate_cn = nr_temp_plus_cn / nr_total_cn if exlgroup!=.** part time **bysort exlgroup pb020: egen nr_parttime_cn = total(parttime)gen parttime_rate_cn = nr_parttime_cn / nr_total_cn if exlgroup!=.** unemployment **bysort exlgroup pb020: egen nr_unempl_cn = total(unempl)gen unempl_rate_cn = nr_unempl_cn / nr_total_cn if exlgroup!=.** Labeling **label variable nr_temp_plus_cn "Number of temporary contracted (or family worker), by Country"label variable temp_plus_rate_cn "Rate of temporary contracted (or family worker), by Country"label variable nr_parttime_cn "Number of parttime workers, by Country"label variable parttime_rate_cn "Rate of parttime workers, by Country"label variable nr_unempl_cn "Number of unemployed, by Country"label variable unempl_rate_cn "Rate of unemployed, by Country"

* 3.2 Country averages of vulnerability bysort pb020: egen cn_mean_temp = mean(temp_plus)bysort pb020: egen cn_mean_part = mean(parttime)bysort pb020: egen cn_mean_unempl = mean(unempl)label variable cn_mean_temp "Mean of temporary contracted (or family worker), by Country"label variable cn_mean_part "Mean of parttime workers, by Country"label variable cn_mean_unempl "Mean of unemployed, by Country"

* 3.3 "Normalized" group-specific values
** "Temporaryness", "Parttimeness" und "Unemploymentness" for each baseline group **
** This is, group-specific rate - country average, i.e. relative vulnerability **gen temporaryness_cn = (temp_plus_rate_cn*100)-(cn_mean_temp*100)gen parttimeness_cn = (parttime_rate_cn*100) - (cn_mean_part*100)gen unemploymentness_cn = (unempl_rate_cn*100) - (cn_mean_unempl*100)label variable temporaryness_cn "'Temporaryness' [temporary contracted in exlgroup - mean of temporary], by Country"label variable parttimeness_cn "'Parttimeness' [parttime workers in exlgroup - mean of parttime], by Country"label variable unemploymentness_cn "'Unemploymentness' [unemployed in exlgroup - mean of unemployed], by Country"** Standardize values to to different scales **egen temporaryness_cn_std = std(temporaryness_cn)egen parttimeness_cn_std = std(parttimeness_cn)egen unemploymentness_cn_std = std(unemploymentness_cn)* 3.4 Generate group- and country-specific outsiderness values

** This is an (unweighted) average of the three group-specific measures of relative vulnerability **gen outsiderness2c = ((temporaryness_cn_std + parttimeness_cn_std + unemploymentness_cn_std) / 3)label variable outsiderness2c "Risk-based continuous 'Outsiderness', standardized values temp/part/unempl, by Country" 

***********************************************************************
* 4. Export Outsiderness values
***********************************************************************

* Table of group- and country-specific values of outsiderness (to merge with ESS data)

table exlgroups pb020, content(mean outsiderness2c)

* save manually to excel (copy table)

* load excel table to reshape into long format

clear all
cd "/Volumes/projects$/dualization/replicationJoP"
import excel "outsiderness.xlsx", sheet("Blatt1") firstrow
rename * outsiderness2c*
rename outsiderness2cexlgroup exlgroups
reshape long outsiderness2c, i(exlgroups) j(cntry) string 
sort cntry exlgroups

* generate analoguous categories for partner's occupational group and outsiderness

* save file in .dta-format to merge with ESS data
save "outsiderness_tomerge.dta", replace

* save file for partner's outsiderness
rename exlgroups exlgroups_sp
rename outsiderness2c outsiderness2c_sp
save "outsiderness_sp_tomerge.dta", replace

